app.controller("baseController", function ($scope) {

    $scope.paginationConf = {
        currentPage: 1,
        totalItems: 10,
        itemsPerPage: 10,
        perPageOptions: [10, 20, 30, 40, 50],
        onChange: function () {
            $scope.reloadList();//重新加载
        }
    };
    $scope.reloadList = function () {
        $scope.search($scope.paginationConf.currentPage, $scope.paginationConf.itemsPerPage);
    };
    $scope.selectIds = [];//选项数组
    $scope.updateSelection = function ($event, id) {
        if ($event.target.checked) {//元素被选中
            $scope.selectIds.push(id);
        } else {
            var num = $scope.selectIds.indexOf(id);
            $scope.selectIds.splice(num, 1);
        }
    }
    $scope.searchEntity = {};

    $scope.jsonToString = function (jsonString, key) {
        var parse = JSON.parse(jsonString);
        var value = "";
        for (var i = 0; i < parse.length; i++) {
            if (i > 0) {
                value += "," + parse[i][key];
            }
            value += parse[i][key];
        }
        return value;
    }
//判断是非第一次点击                   集合    集合中的key  集合中的value
   $scope.searchObjectByKey = function (list,key,keyValue) {
        for (var i = 0;i< list.length;i++) {
            if (list[i][key] == keyValue){
                return list[i];
            }
        }
       return null;

   };

});


